﻿using System;
using System.Collections.Generic;
using System.Text;
using System.CodeDom;
using System.Collections;
using System.Text.RegularExpressions;

namespace _0512063_0512082
{
     class CodeGenerator
    {
        public static String prefix_out = "Xuat";
        public static String prefix_in = "Nhap";
        public static String serparator = "_";
        public static String start_package = "\r\n{\r\n";
        public static String end_package = "}";
        public static String open_func = "(";
        public static String end_func = ")";
        public static String dummy = " kq";
        public static String tab = "\t";
        public static String endline = ";\r\n";
        public static String comma = ", ";
        public static String inputdirection = "Nhap vao tham so ";
        public static String prefix_check = "Kiemtra";
        public static String prefix_process = "XuLy";
        public static String nspace = "CodeDom";
        public static String leakdata = "Du lieu khong hop le";

        protected CodeMemberMethod mainMethod;
        public CodeGenerator(CodeMemberMethod method)
        {
            mainMethod = method;
        }

        protected String getMethodName()
        {
            return mainMethod.Name;
        }

        protected String getReturnType() {
            if (mainMethod.ReturnType != null)
                return mainMethod.ReturnType.BaseType;
            else return String.Empty;
            
        }

        protected List<Object> getParameters() {
            CodeParameterDeclarationExpressionCollection parameters = mainMethod.Parameters;
            List<object> rs = new List<object>();
            foreach (CodeParameterDeclarationExpression p in parameters)
            {
                rs.Add(p);
            }
            return rs;
        }

        public virtual Object inputFunction(){return null;}
        public virtual Object outputFunction() { return null; }
        public virtual Object checkFunction() { return null; }
        public virtual Object processFunction() { return null; }
        public virtual Object mainFunction() { return null; }
        public virtual Object start() { return null; }
        protected string FormatCode(string CodeToFormat)
        {
            //string FormattedCode = Regex.Replace(CodeToFormat, "\n", "<br>");
            //FormattedCode = Regex.Replace(FormattedCode, "  ", "");
            //FormattedCode = Regex.Replace(FormattedCode, ",", ", ");
            return CodeToFormat;
        }


    }
}
